// FLTK Image class which preserves aspect ratio when drawing
// Copyright 2005 (C) Ralph Thomas

#ifndef TOOLKIT_FLTK_ASPECTIMAGE_H
#define TOOLKIT_FLTK_ASPECTIMAGE_H

#include <fltk/Image.h>

namespace fltk {
	//
	/// The AspectImage class preserves the aspect ratio of any image it's
	/// given to draw. It wraps the source image it's given, and acts as an
	/// Adaptor.
	//
	class AspectImage : public Image {
		Image* _source;
	  public:
		//
		/// Create a new AspectImage.
		//
		AspectImage();
		//
		/// Destroy this AspectImage instance. Note that this does NOT
		/// delete the source image.
		//
		virtual ~AspectImage();
		//
		/// Set the source image. This image is the one which is drawn
		/// with correct aspect ratio. Call setImage( 0 ) to remove the
		/// source image when done.
		///
		/// \param	source	the source image to draw from.
		//
		void setSource( fltk::Image* source );
		//
		// from fltk::Image.
		//
		virtual void _measure( int& w, int& h ) const;
		virtual void _draw( const fltk::Rectangle& r ) const;
		virtual void update();
	};
};

#endif

